package com.example.zwh.computershop.handleDataClient;

import com.example.zwh.computershop.sqlModel.User;

public class Test {

	public static void main(String[] args) {
		User user = new User();
		String un = "37265922@qq.com";
		String ps = "z";
		//登录
		int state = handleData.handleLogin(un, ps, user);
		if (state == 5) {
			System.out.println("联网出错");
		}else if (state == 1) {
			System.out.println("账户不存在");
		}else if (state == 3) {
			System.out.println("密码错误");
		}else {
			System.out.println("登录成功");
			//user.printInfo();
		}
		
		//注册
		User user2 = new User();
		
		user2.setUsername("z");
		user2.setPassword("z");
		user2.setRole(1);
		user2.setHeadPortraitUrl("z");
		user2.setEmail("38275922@qq.com");
		user2.setPhone("110");
		
		int state2 = handleData.handleRegister(user2);
		System.out.println(state2);
		if (state == 5) {
			System.out.println("联网出错");
			
		}else if (state2 == 2) {
			System.out.println("注册成功");
			//获取uid
			handleData.handleLogin(user2.getEmail(), user2.getPassword(), user2);
		}else if (state2 == 1) {
			System.out.println("账户已存在");
		}
		handleData.handleLogin(user2.getEmail(), user2.getPassword(), user2);
		user2.printInfo();
		user2.setUsername("z");
		user2.setPassword("z2");
		user2.setRole(1);
		user2.setHeadPortraitUrl("z");
		user2.setEmail("38275922@qq.com");
		user2.setPhone("130");
		state = handleData.handleInfo(user2);
		
		if (state == 2) {
			System.out.println("修改成功");
		}else if (state == 1) {
			System.out.println("修改失败");
		}else if (state == 4) {
			System.out.println("修改失败");
		}
		
	}

}
